using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Device.Location;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Windows;
namespace Microsoft.Phone.Controls.Maps.Core
{
	public abstract class MapMode
	{
		private static readonly Range<double> defaultZoomRange = new Range<double>(1.0, 21.0);
		private static readonly Range<double> defaultHeadingRange = new Range<double>(0.0, 360.0);
		private static readonly Range<double> defaultPitchRange = new Range<double>(-90.0, 90.0);
		private readonly AttributionCollection attributions = new AttributionCollection(new ObservableCollection<AttributionInfo>());
		private CultureInfo culture;
		public event EventHandler<MapEventArgs> TargetViewChanged
		{
			[MethodImpl(32)]
			add
			{
				this.TargetViewChanged = (EventHandler<MapEventArgs>)Delegate.Combine(this.TargetViewChanged, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.TargetViewChanged = (EventHandler<MapEventArgs>)Delegate.Remove(this.TargetViewChanged, value);
			}
		}
		public event EventHandler<ProjectionChangedEventArgs> ProjectionChanged
		{
			[MethodImpl(32)]
			add
			{
				this.ProjectionChanged = (EventHandler<ProjectionChangedEventArgs>)Delegate.Combine(this.ProjectionChanged, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.ProjectionChanged = (EventHandler<ProjectionChangedEventArgs>)Delegate.Remove(this.ProjectionChanged, value);
			}
		}
		public CultureInfo Culture
		{
			get
			{
				if (this.culture != null)
				{
					return this.culture;
				}
				return CultureInfo.get_CurrentUICulture();
			}
			set
			{
				this.culture = value;
				this.OnCultureChanged();
			}
		}
		public virtual GeoCoordinate Center
		{
			get;
			set;
		}
		public virtual GeoCoordinate TargetCenter
		{
			get
			{
				return this.Center;
			}
		}
		public virtual double ZoomLevel
		{
			get;
			set;
		}
		public virtual double TargetZoomLevel
		{
			get
			{
				return this.ZoomLevel;
			}
		}
		public virtual double Heading
		{
			get;
			set;
		}
		public virtual double TargetHeading
		{
			get
			{
				return this.Heading;
			}
		}
		public virtual double Pitch
		{
			get;
			set;
		}
		public virtual double TargetPitch
		{
			get
			{
				return this.Pitch;
			}
		}
		public virtual double Scale
		{
			get;
			set;
		}
		public virtual double TargetScale
		{
			get
			{
				return this.Scale;
			}
		}
		public virtual Range<double> ZoomRange
		{
			get
			{
				return MapMode.defaultZoomRange;
			}
		}
		public virtual Range<double> HeadingRange
		{
			get
			{
				return MapMode.defaultHeadingRange;
			}
		}
		public virtual Range<double> PitchRange
		{
			get
			{
				return MapMode.defaultPitchRange;
			}
		}
		public virtual LocationRect BoundingRectangle
		{
			get
			{
				return LocationRect.CreateLocationRect(new GeoCoordinate[]
				{
					this.ViewportPointToLocation(new Point(0.0, 0.0)),
					this.ViewportPointToLocation(new Point(0.0, this.ViewportSize.get_Height())),
					this.ViewportPointToLocation(new Point(this.ViewportSize.get_Width(), this.ViewportSize.get_Height())),
					this.ViewportPointToLocation(new Point(this.ViewportSize.get_Width(), 0.0))
				});
			}
		}
		public virtual LocationRect TargetBoundingRectangle
		{
			get
			{
				return this.BoundingRectangle;
			}
		}
		public virtual AttributionCollection Attributions
		{
			get
			{
				return this.attributions;
			}
		}
		public Size ViewportSize
		{
			get;
			set;
		}
		public AnimationLevel AnimationLevel
		{
			get;
			set;
		}
		public virtual CredentialsProvider CredentialsProvider
		{
			get;
			set;
		}
		public virtual bool IsDownloading
		{
			get
			{
				return false;
			}
		}
		public virtual bool IsIdle
		{
			get
			{
				return true;
			}
		}
		public virtual UIElement Content
		{
			get
			{
				return null;
			}
		}
		public virtual UIElement ForegroundContent
		{
			get
			{
				return null;
			}
		}
		public virtual ModeBackground ModeBackground
		{
			get
			{
				return ModeBackground.Dark;
			}
		}
		public abstract void SetView(GeoCoordinate center, double zoomLevel, double heading, double pitch, bool animate);
		public abstract void SetView(LocationRect boundingRectangle, bool animate);
		public abstract Point LocationToViewportPoint(GeoCoordinate location);
		public virtual IEnumerable<Point> LocationToViewportPoint(IEnumerable<GeoCoordinate> locations)
		{
			return Enumerable.Select<GeoCoordinate, Point>(locations, (GeoCoordinate location) => this.LocationToViewportPoint(location));
		}
		public virtual Rect LocationToViewportPoint(LocationRect boundingRectangle)
		{
			Point point = this.LocationToViewportPoint(boundingRectangle.Northwest);
			Point point2 = this.LocationToViewportPoint(boundingRectangle.Southeast);
			return new Rect(point, point2);
		}
		public abstract bool TryLocationToViewportPoint(GeoCoordinate location, out Point viewportPoint);
		public abstract GeoCoordinate ViewportPointToLocation(Point viewportPoint);
		public abstract bool TryViewportPointToLocation(Point viewportPoint, out GeoCoordinate location);
		public virtual void OnMapDrag(MapDragEventArgs e)
		{
		}
		public virtual void OnMapFlick(MapFlickEventArgs e)
		{
		}
		public virtual void OnMapZoom(MapZoomEventArgs e)
		{
		}
		public virtual void Activating(MapMode previousMode, MapLayerBase modeLayer, MapLayerBase modeForegroundLayer)
		{
		}
		public virtual void Activated(MapLayerBase modeLayer, MapLayerBase modeForegroundLayer)
		{
		}
		public virtual void Deactivating()
		{
		}
		public virtual void ViewportSizeChanged(Size viewportSize)
		{
			this.ViewportSize = viewportSize;
		}
		protected virtual void OnTargetViewChanged()
		{
			EventHandler<MapEventArgs> targetViewChanged = this.TargetViewChanged;
			if (targetViewChanged != null)
			{
				targetViewChanged.Invoke(this, new MapEventArgs());
			}
		}
		protected virtual void OnProjectionChanged(ProjectionUpdateLevel updateLevel)
		{
			EventHandler<ProjectionChangedEventArgs> projectionChanged = this.ProjectionChanged;
			if (projectionChanged != null)
			{
				projectionChanged.Invoke(this, new ProjectionChangedEventArgs(updateLevel));
			}
		}
		protected virtual void OnCultureChanged()
		{
		}
	}
}
